#!/bin/bash

echo "=========================================="
echo "测试 Elasticsearch 查询"
echo "=========================================="

ES_URL="http://117.72.38.248:19200"

# 测试商品查询
echo "1. 测试商品查询 (iPhone)..."
curl -s "$ES_URL/products/_search?pretty" \
  -H "Content-Type: application/json" \
  -d '{
    "query": {
      "match": {
        "name": "iPhone"
      }
    },
    "size": 3
  }'
echo ""

# 测试城市查询
echo "2. 测试城市查询 (北京)..."
curl -s "$ES_URL/cities/_search?pretty" \
  -H "Content-Type: application/json" \
  -d '{
    "query": {
      "match": {
        "name": "北京"
      }
    },
    "size": 3
  }'
echo ""

# 测试用户查询
echo "3. 测试用户查询 (张)..."
curl -s "$ES_URL/users/_search?pretty" \
  -H "Content-Type: application/json" \
  -d '{
    "query": {
      "match": {
        "username": "张"
      }
    },
    "size": 3
  }'
echo ""

echo "=========================================="
echo "测试完成"
echo "=========================================="
